<template>
	<view class="">
		<Loading class="loading-box" v-show="!isLoading" :isStatus='loadStatus'></Loading>

		<cu-custom bgColor="" :isBack="true" textRight="false" type="1">
			<block slot="backText" class="titilestyle" style="font-size: 35rpx;">{{title}}</block>

		</cu-custom>
		
		<scroll-view scroll-y="true" :style="{height: swiperHeight+'px'}"  v-if="pageData">
			
			<view class="content">
				<view>
					<view class="flex list" :class="{one: index == 0 && pageData.res.state == 3}"
						v-for="(item, index) in pageData.res.data" :key="index">
						<view class="time">
							<view class="day">{{spliceTime(item.time).after}}</view>
							<view>{{spliceTime(item.time).before}}</view>
						</view>
						<view class="info flex1">
							<view class="title">{{index == 0 && pageData.res.state == 3 ? '已签收' : '配送中'}}</view>
							<view class="text">{{item.context}}</view>
						</view>
					</view>
				</view>
			</view>
		</scroll-view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				pageData: null,
				isLoading: false, //是否加载完成显示
				loadStatus: 'load',
				title: "运单详情",
				swiperHeight:0,
			}
		},

		onLoad(option) {
			this.getLogistica(option.order_id);
		},
		mounted(){
			this.getInfo().then((e) => {
			
				this.swiperHeight = e.screenHeight - (e.custom.top + e.custom.height)-5;
			
			});
		},

		methods: {
			//获取物流信息
			getLogistica(order_id) {
				this.apiRequest('/buyer/orderLogistica', {
					order_id: order_id
				}).then(res => {


					if (res.code != 200) {
						uni.showToast({
							title: res.msg,
							icon: "none"
						})
						setTimeout(()=>{
							uni.navigateBack({
								delta:1
							})              
						},1000)
						return
					}
					this.isLoading = true;
					this.pageData = res.data;
				})

			},
			/**
			 * 改变时间
			 */
			spliceTime(time) {
				let T = time.split(" ");
				let d = {
					after: T[0],
					before: T[1]
				}
				return d;


			}
		}
	}
</script>
<style>
	.titilestyle {
		font-weight: 550;
		font-size: 35upx;
		display: block;
		white-space: nowrap;
		align-items: center;
		overflow: hidden;
		text-overflow: ellipsis;
	}
</style>
<style lang="scss" scoped>
	.head{
		padding: 32rpx 46rpx 56rpx 5rpx;
	}
	.head-item {
		color: #A4A4A4;
	}
	
	.cuIcon-copy {
		font-size: 32rpx;
	
	}
	
	.bottom-border {
		border-bottom: 2rpx solid rgba(164, 164, 164, 0.3);
	}
	.flex {
		display: flex;
		flex-direction: row;
	}
	.flex1 {
		flex: 1;
	}
	.ali-c {
		display: flex;
		flex-direction: row;
		align-items: center;
	}

	.bgf {
		background-color: #fff;
	}

	.express {
		background-color: #ffffff;
		border-radius: 20rpx;
		margin: 30rpx 20rpx 30rpx 20rpx;

		.top {
			padding: 28rpx 29rpx 25rpx 29rpx;

			.img {
				display: block;
				width: 88rpx;
				height: 88rpx;
				border-radius: 50%;
			}

			.text {
				margin-left: 20rpx;
				.text1 {
					margin-bottom: 6rpx;
					font-size: 28rpx;
					color: #000000;
				}

				.text2 {
					font-size: 20rpx;
					color: #000000;
				}
			}
		}

		.right {
			background-color: rgba(8, 175, 254, 0.02);
			border-radius: 0rpx 0rpx 20rpx 20rpx;
			padding: 15rpx 30rpx 20rpx 30rpx;

			.text {
				color: #666666;
				font-size: 22rpx;
			}
		}
	}

	//收货地址
	.content {

		padding: 56rpx 46rpx 56rpx 5rpx;
		border-radius: 20rpx;
		.list {
			&:first-child {
				.info::before {
					bottom: -20rpx;
					margin-top: 40rpx;
					border-left: 1px dashed #e5e5e5;
				}

				.title {
					margin-bottom: 56rpx;

					&::before {
						width: 46rpx;
						height: 46rpx;
						left: -23rpx;
						background: url('') no-repeat center;
						background-size: 46rpx 46rpx;
					}
				}
			}

			&:last-child {
				.info::before {
					height: 32rpx;
				}
			}

			&.one {
				.info::before {
					margin-top: 20rpx;
				}

				.title {
					color: #1a1a1a;

					&::before {
						width: 32rpx;
						height: 32rpx;
						left: -18rpx;
						background: url('') no-repeat center;
						background-size: 46rpx 46rpx;
					}
				}

				.text {
					color: #666;
				}

				.time {
					color: #333;

					.day {
						font-size: 24rpx;
					}
				}
			}
		}

		.time {
			width: 200rpx;
			padding-right: 30rpx;
			font-size: 20rpx;
			text-align: right;
			color: #999;

			.day {
				margin-bottom: 4rpx;
			}
		}

		.info {
			position: relative;
			padding-top: 12rpx;
			color: #999;
			font-size: calc(100vw*(24/750));
			font-family: sans-serif;

			&::before {
				content: "";
				position: absolute;
				left: 0;
				top: 0;
				bottom: 0;
				z-index: 1;
				width: 0;
				border-left: 1px solid #e5e5e5;
			}

			.title {
				position: relative;
				margin-bottom: 10rpx;
				padding-left: 32rpx;
				font-size: 28rpx;

				&::before {
					content: "";
					position: absolute;
					left: -3px;
					top: 0;
					bottom: 0;
					z-index: 1;
					width: 7px;
					height: 7px;
					margin: auto 0;
					border-radius: 50%;
					background-color: #cecece;
				}

				&.address {
					font-size: 24rpx;
					color: #333;
				}
			}

			.text {
				font-size: calc(100vw*(24/750));
				padding: 0 0 32rpx 32rpx;
			}
		}
	}
</style>
